/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbf', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AscpPurchasingPurchaseOrderSupplierConfirmErpApiRequest {
  purchaseOrderNo?: string(name='purchaseOrderNo', description='采购单号'),
  supplierId?: long(name='supplierId', description='二级供应商ID'),
  tenantId?: string(name='tenantId', description='租户ID'),
  items?: [ 
    {
      productId?: long(name='productId', description='货品ID'),
      confirmQuantity?: float(name='confirmQuantity', description='确认数量'),
      orderLineId?: long(name='orderLineId', description='货品行ID'),
    }
  ](name='items', description='货品行确认信息'),
}

model AscpPurchasingPurchaseOrderSupplierConfirmErpApiResponseBody = {
  success?: boolean(name='success', description='是否确认成功'),
  errorCode?: string(name='errorCode', description='错误Code'),
  retry?: boolean(name='retry', description='是否可重试'),
  errorMsg?: string(name='errorMsg', description='错误码'),
}

model AscpPurchasingPurchaseOrderSupplierConfirmErpApiResponse = {
  headers: map[string]string(name='headers'),
  body: AscpPurchasingPurchaseOrderSupplierConfirmErpApiResponseBody(name='body'),
}

async function ascpPurchasingPurchaseOrderSupplierConfirmErpApi(request: AscpPurchasingPurchaseOrderSupplierConfirmErpApiRequest): AscpPurchasingPurchaseOrderSupplierConfirmErpApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return ascpPurchasingPurchaseOrderSupplierConfirmErpApiWithOptions(request, headers, runtime);
}

async function ascpPurchasingPurchaseOrderSupplierConfirmErpApiWithOptions(request: AscpPurchasingPurchaseOrderSupplierConfirmErpApiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AscpPurchasingPurchaseOrderSupplierConfirmErpApiResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.purchaseOrderNo)) {
    body.purchaseOrderNo = request.purchaseOrderNo;
  }
  if (!Util.isUnset(request.supplierId)) {
    body.supplierId = request.supplierId;
  }
  if (!Util.isUnset(request.tenantId)) {
    body.tenantId = request.tenantId;
  }
  if (!Util.isUnset(request.items)) {
    body.items = request.items;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('AscpPurchasingPurchaseOrderSupplierConfirmErpApi', '2021-07-01_20-10-58-51', 'HTTPS', 'POST', 'AK', `/AscpPurchasingPurchaseOrderSupplierConfirmErpApi`, 'json', req, runtime);
}

